//
//  Item1GetCardTypeRequestProvider.m
//  SLRequest
//
//  Created by 虞嘉伟 on 2025/4/2.
//  
  

#import "Item1GetCardTypeRequestProvider.h"
#import "Item1GetCardTypeRequest.h"

@implementation Item1GetCardTypeRequestProvider

/// 图片上传
/// - Parameters:
///   - productId: 产品id
///   - success: 成功回调
///   - failure: 失败回调
+ (void)requestCardTypeWithProductId:(NSString *)productId
                             success:(void(^)(NSDictionary *dict))success
                             failure:(void(^)(YTKRequest *request))failure {
    Item1GetCardTypeRequest *request = [Item1GetCardTypeRequest new];
    request.scenery = productId;
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}
@end
